/**
 * @Author 丁锦涛
 * @create 2021/10/10 14:24
 */
public class let {
    public static void main(String[] args) {

        System.out.println(arrangeCoins(
                1804289383));
    }
    public static int arrangeCoins(int n) {
        if(n==0)return 1;
        if(n==1)return 1;
        int l=1;
        int r=n;
        while(l<=r){
            int mid=l+(r-l)/2;
            int need=mid*(mid+1)/2;
            if(need==n)return mid;
            if(need>n){
                r=mid-1;
            }else{
                if(need<n&&n-need>=0&&n-need<=mid+1){
                    if(n-need==mid+1)return mid+1;
                    return mid;
                }else{
                    l=mid+1;
                }
            }
        }
        return 0;
    }
}
